﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Deployment.BuildManager.Common;

namespace Deployment.BuildManager.Console
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length < 7)
            {
                System.Console.WriteLine("Número inválido de parâmetros.");
                System.Console.WriteLine("Parâmetros:");
                System.Console.WriteLine("1 - Produto");
                System.Console.WriteLine("2 - URI Branch;");
                System.Console.WriteLine("3 - URI Setup;");
                System.Console.WriteLine("4 - Sigla Módulo;");
                System.Console.WriteLine("5 - Versão;");
                System.Console.WriteLine("6 - Pasta local para download;");
                System.Console.WriteLine("7 - Titulo do Pacote;");
                System.Console.WriteLine("8 em diante - Descrições;");
                return;
            }

            List<string> descriptions = new List<string>();

            for (int i = 7; i < args.Length; i++)
            {
                descriptions.Add(args.GetValue(i).ToString());
            }

            ExecuteTasks tasks = new ExecuteTasks();

            tasks.MessageReceived += new EventHandler<Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs>(tasks_MessageReceived);

            tasks.Execute(args.GetValue(0).ToString(), args.GetValue(1).ToString(), args.GetValue(2).ToString(), 
                          args.GetValue(3).ToString(), args.GetValue(4).ToString(), args.GetValue(5).ToString(), 
                          args.GetValue(6).ToString(), descriptions);

            //tasks.Execute("$/SinaCLI/HotFix/NET/1.8.131073.1", "$/SINACOR/Setup/PROD/1.8.0.0", "CLI");
        }

        static void tasks_MessageReceived(object sender, Deployment.BuildManager.ExternalProcess.Common.MessageEventArgs e)
        {
            System.Console.WriteLine(e.Message);
        }
    }
}
